﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Lion.WeiXin.Core.Models;
using Lion.WeiXin.Core.Data;
namespace Lion.WeiXin.Core
{
   public class VipCardUseLogHelper
    {
       /// <summary>
       /// 写入消费记录
       /// </summary>
       /// <param name="cardID">卡号ID</param>
       /// <param name="title">标题</param>
       /// <param name="useType">使用类型：充值，消费</param>
       /// <param name="orderId">订单ID ，当为充值时，为空</param>
       /// <param name="payment">消费金额</param>
       public static void WriteLog(string cardID, string title, VipCardUseEnum useType,string orderId, decimal payment,string creator="system")
       {
           //加入订单消费记录
           VipCardUseLogModel logModel = new VipCardUseLogModel();
           logModel.Card_ID = cardID;
           logModel.Title = title;
           logModel.Dic_UseType = ((int)useType).ToString();
           logModel.Order_ID = orderId;
           logModel.Payment = payment;
           logModel.CreateDate = DateTime.Now;
           logModel.Creator = creator;

           DBContext db = new DBContext();
           VipCardModel cardModel = db.VipCards.GetModel(cardID);
           if (cardModel != null)
           {
               logModel.RealName = cardModel.RealName;
           }
           db.VipCardUseLogs.Add(logModel);
       }
    }
}
